# _*_ coding: utf-8 _*_
import xadmin
from xadmin import views
from xadmin.plugins.auth import UserAdmin
from .models import Region, Company, UserJob, Department, UserProfile, CustomerProfile

class RegionAdmin(object):
    list_display = ['name', 'parent', 'updated_at', 'created_at']
    search_fields = ['name', ]
    list_filter = ['name', 'parent', 'updated_at', 'created_at']
    model_icon = 'fa fa-map-marker'

class CompanyAdmin(object):
    list_display = ['name', 'logo', 'domainName', 'address', 'area_code', 'description', 'region']
    search_fields = ['name', 'domainName', 'address', 'area_code', 'description', 'region']
    list_filter = ['name', 'domainName', 'address', 'area_code', 'description', 'region', 'updated_at', 'created_at']
    model_icon = 'fa fa-building-o'

class UserJobAdmin(object):
    list_display = ['name', 'updated_at', 'created_at']
    search_fields = ['name', ]
    list_filter = ['name', 'updated_at', 'created_at']
    model_icon = 'fa fa-cog'

class DepartmentAdmin(object):
    list_display = ['name', 'parent', 'company', 'jobs']
    search_fields = ['name', ]
    list_filter = ['name', 'parent', 'company', 'jobs', 'updated_at', 'created_at']
    model_icon = 'fa fa-users'

class CustomerProfileAdmin(object):
    list_display = ['name', 'gender', 'mobile', 'avator', 'address', 'sale', 'created_at']
    search_fields = ['name', 'mobile', 'address']
    list_filter = ['name', 'gender', 'mobile', 'avator', 'address', 'sale', 'updated_at', 'created_at']
    model_icon = 'fa fa-meh-o'
    ordering = ['-created_at']


# class CustomerProfileAdmin(object):
#     list_display = ['name', 'gender', 'mobile', 'avator', 'address', 'description', '']

#         name = models.CharField(max_length=128, verbose_name=u"客户姓名", default="")
#     gender = models.CharField(max_length=6, choices=(("male", u"男"), ("female", u"女")), default="female",
#                               verbose_name=u"性别")
#     mobile = models.CharField(max_length=11, null=True, blank=True, verbose_name=u"手机")
#     avator = models.ImageField(upload_to="image/userprofile/%Y/%m", default=u"image/userprofile/default.png", max_length=100, verbose_name=u"头像")
#     address = models.CharField(max_length=255, verbose_name=u"地址", default="", null=True, blank=True)
#     description = models.CharField(max_length=255, verbose_name=u"客户简介", default="")
#     sale = models.ForeignKey(UserProfile, verbose_name=u"营销", related_name='salecustomer', null=True, blank=True)

#     updated_at = models.DateTimeField(auto_now=True, verbose_name=u"更新时间")
#     created_at = models.DateTimeField(auto_now_add=True, verbose_name=u"创建时间")





xadmin.site.register(Region, RegionAdmin)
xadmin.site.register(Company, CompanyAdmin)
xadmin.site.register(UserJob, UserJobAdmin)
xadmin.site.register(Department, DepartmentAdmin)
xadmin.site.register(CustomerProfile, CustomerProfileAdmin)

class BaseSetting(object):
    enable_themes = True
    use_bootswatch = True


class GlobalSetting(object):
    site_title = "精选管理系统"
    site_footer = "四川二十四城科技有限公司"
    menu_style = "accordion"


xadmin.site.register(views.BaseAdminView, BaseSetting)
xadmin.site.register(views.CommAdminView, GlobalSetting)

